package com.lanqiao.attendance.handler;


import com.lanqiao.attendance.vo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * @program: attendance
 * @description
 * @author: 刘 华
 * @create: 2022-07-08 18:49
 **/

//对加了@Controller注解的方法进行拦截处理 AOP的实现
@ControllerAdvice
@SuppressWarnings("all")
public class GlobalExceptionHandler {
    //进行异常处理，处理Exception.class的异常
    @ExceptionHandler(Exception.class)
    @ResponseBody //返回json数据
    public Result doException(Exception ex){
        ex.printStackTrace();
        return Result.fail(-999,ex.getMessage());
    }

}
